<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  <meta name="misapplication-tap-highlight" content="no" />
  <meta name="HandheldFriendly" content="true" />
  <meta name="MobileOptimized" content="320" />
  <link rel="stylesheet" href="cs.css">
  <title>QmSdk-Map</title>
</head>

<body>
  <div class="title">文档信息</div>
  <div class="inputItem">文件名称：<input type="text" value="附件1：职级评定申请及标准-软件工程师.xlsx" class="input url" id="filename" />
  </div>
  <div>PS.文件名称必须带扩展名</div>
  <div class="inputItem">下载URL：<input type="text"
      value="http://sso.championsoft.net/attachment/down/5f2a8ee6-4ed3-452f-90dc-e0c099f88111" class="input url"
      id="url" />
  </div>

  <div class="button" onclick="scanFile()">
    调用预览
  </div>

  <div class="info">
  </div>

  <script src="../qmsdk.js"></script>
  <script>
    let that = this;
    let infoBox = document.querySelector(".info");

    function scanFile() {
      var downloadurl = document.querySelector("#url").value;
      var filename = document.querySelector("#filename").value;
      if (!downloadurl || !filename) {
        p.innerText = "请填写文件名称(必须带扩展名)、文件下载URL";
        infoBox.appendChild(p);
        return;
      }
      let p = document.createElement("p");
      window.qmSdk.scanFile({
        downloadurl: document.querySelector("#url").value,
        filename: document.querySelector("#filename").value,
        success: () => {
          p.innerText = "打开文档预览成功";
          infoBox.appendChild(p);
        },
        fail: err => {
          console.log(err);
          p.innerText = err;
          infoBox.appendChild(p);
        }
      })
    }

  </script>
</body>

</html>
